﻿using University.Workshop.Business;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using University.Workshop.Model;

namespace University.Workshop.Tests
{
    
    
    /// <summary>
    ///This is a test class for UserUpdateManagerTest and is intended
    ///to contain all UserUpdateManagerTest Unit Tests
    ///</summary>
    [TestClass()]
    public class UserUpdateManagerTest
    {


        private TestContext testContextInstance;

        /// <summary>
        ///Gets or sets the test context which provides
        ///information about and functionality for the current test run.
        ///</summary>
        public TestContext TestContext
        {
            get
            {
                return testContextInstance;
            }
            set
            {
                testContextInstance = value;
            }
        }

        #region Additional test attributes
        // 
        //You can use the following additional attributes as you write your tests:
        //
        //Use ClassInitialize to run code before running the first test in the class
        //[ClassInitialize()]
        //public static void MyClassInitialize(TestContext testContext)
        //{
        //}
        //
        //Use ClassCleanup to run code after all tests in a class have run
        //[ClassCleanup()]
        //public static void MyClassCleanup()
        //{
        //}
        //
        //Use TestInitialize to run code before running each test
        //[TestInitialize()]
        //public void MyTestInitialize()
        //{
        //}
        //
        //Use TestCleanup to run code after each test has run
        //[TestCleanup()]
        //public void MyTestCleanup()
        //{
        //}
        //
        #endregion


        /// <summary>
        ///A test for updateUser
        ///</summary>
        [TestMethod()]
        public void updateUserTestSuccesfully()
        {
            string phone = "4298950"; // TODO: Initialize to an appropriate value
            string mobilePhone = "76474168"; // TODO: Initialize to an appropriate value
            string city = "Cochabamba"; // TODO: Initialize to an appropriate value
            string department = "Cochabamba"; // TODO: Initialize to an appropriate value
            string email = "fabi_aqy@hotmail.com"; // TODO: Initialize to an appropriate value
            UserRegistrationManager.RegisterUser("Fabiola", "Quiroga", 'f', DateTime.Now, email, "yankovic123", "yankovic123", department, city, mobilePhone, phone);
            User user = UserUpdateManager.UpdateUser(phone, mobilePhone, city, department, email);

            Assert.AreNotEqual(null, user);
            Assert.AreEqual(Convert.ToInt32(phone), user.ContactInformation.Phone);
            Assert.AreEqual(Convert.ToInt32(mobilePhone),user.ContactInformation.MobilePhone);
            Assert.AreEqual(city,user.ContactInformation.City);
            Assert.AreEqual(department, user.ContactInformation.Department);
        }

        [TestMethod()]
        [ExpectedException(typeof(ValidationException))]
        public void updateUserTestBlankItems()
        {
            
            string phone = string.Empty; // TODO: Initialize to an appropriate value
            string mobilePhone = string.Empty; // TODO: Initialize to an appropriate value
            string city = string.Empty; // TODO: Initialize to an appropriate value
            string department = string.Empty; // TODO: Initialize to an appropriate value
            string email = string.Empty; // TODO: Initialize to an appropriate value
            User user = UserUpdateManager.UpdateUser(phone, mobilePhone, city, department, email);
        }

         [TestMethod()]
         [ExpectedException(typeof(ValidationException))]
        public void updateUserTestInvalidPhone()
        {
            string phone = "aa"; // TODO: Initialize to an appropriate value
            string mobilePhone = "76474168"; // TODO: Initialize to an appropriate value
            string city = "Cochabamba"; // TODO: Initialize to an appropriate value
            string department = "Cochabamba"; // TODO: Initialize to an appropriate value
            string email = "fabi_aqy@hotmail.com"; // TODO: Initialize to an appropriate value
            User user = UserUpdateManager.UpdateUser(phone, mobilePhone, city, department, email);
        }


         [TestMethod()]
         [ExpectedException(typeof(ValidationException))]
         public void updateUserTestInvalidMobilePhone()
         {
             string phone = "4298950"; // TODO: Initialize to an appropriate value
             string mobilePhone = "eeee"; // TODO: Initialize to an appropriate value
             string city = "Cochabamba"; // TODO: Initialize to an appropriate value
             string department = "Cochabamba"; // TODO: Initialize to an appropriate value
             string email = "fabi_aqy@hotmail.com"; // TODO: Initialize to an appropriate value
             User user = UserUpdateManager.UpdateUser(phone, mobilePhone, city, department, email);
         }


         [TestMethod()]
         [ExpectedException(typeof(ValidationException))]
         public void updateUserTestInvalidCity()
         {
             string phone = "4298950"; // TODO: Initialize to an appropriate value
             string mobilePhone = "76474168"; // TODO: Initialize to an appropriate value
             string city = "1231233"; // TODO: Initialize to an appropriate value
             string department = "Cochabamba"; // TODO: Initialize to an appropriate value
             string email = "fabi_aqy@hotmail.com"; // TODO: Initialize to an appropriate value
             User user = UserUpdateManager.UpdateUser(phone, mobilePhone, city, department, email);
         }

         
    }
}
